﻿using System.Collections.Generic;
using System.Linq;
using System.Web;
using kunukn.RecommendationEngine.AreaRecommendation.Code.Constants;
using kunukn.RecommendationEngine.AreaRecommendation.Code.Entities;


namespace kunukn.RecommendationEngine.AreaRecommendation.Code.Engine
{
    /// <summary>
    /// Author: Kunuk Nykjaer
    /// Build and setup data structure and item datas
    /// </summary>
    public static class RecommendationEngineBuildAndSetupData
    {
        public static void Run()
        {
            // list of items
            var items = new List<Item>();           
            items.Add(new Item { Color = "#F00", Name = "a" });
            items.Add(new Item { Color = "#F05", Name = "b" });
            items.Add(new Item { Color = "#F50", Name = "c" });
            items.Add(new Item { Color = "#0F0", Name = "d" });
            items.Add(new Item { Color = "#0F5", Name = "e" });
            items.Add(new Item { Color = "#5F0", Name = "f" });
            items.Add(new Item { Color = "#00F", Name = "g" });
            items.Add(new Item { Color = "#05F", Name = "h" });
            items.Add(new Item { Color = "#50F", Name = "i" });

            HttpContext.Current.Application[SessionKeys.Items] = items;

            //Item2Item i2i = new Item2Item(items);
            //HttpContext.Current.Application[SessionKeys.I2I] = i2i;

            int i = 0;
            Dictionary<string,int> lookupNameToIndex = items.ToDictionary(item => item.Name, item => i++);                        
            HttpContext.Current.Application[SessionKeys.LookupNameToIndex] = lookupNameToIndex;
        }
    }
}